package com.fs.book.service.impl;

import com.fs.book.entity.CartItem;
import com.fs.book.mapper.BookMapper;
import com.fs.book.mapper.CartMapper;
import com.fs.book.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartServiceImpl implements CartService {
    @Autowired
    private CartMapper cartMapper;
    @Override
    public void addToCart(CartItem cartItem) {
        cartMapper.save(cartItem);
    }
    @Override
    public List<CartItem> getCartData() {
        return cartMapper.getByUserId();
    }

    @Override
    public void removeFromCart(Integer cartItemId) {
        cartMapper.deleteAll(cartItemId);
    }

    @Override
    public void clearCart() {
        cartMapper.delete();
    }
}
